home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / gnu_oleo_1_2_2.lha / oleo-1.2.2 / cell.h < prev    next >
C/C++ Source or Header  |  1993-03-03  |  5KB  |  164 lines

  1. #ifndef CELLH
  2. #define CELLH
  3. /*    Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
  4.  
  5. This file is part of Oleo, the GNU Spreadsheet.
  6.  
  7. Oleo is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. Oleo is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Oleo; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Various structures and stuff for the spreadsheet */
  22.  
  23. /* A union of possible values for a location in the spreadsheet
  24.    (or a location to evaluate to:  This includes c_r, which
  25.    a VAR, etc may evaluate to, but which no cell can ever contain */
  26. #include "global.h"
  27. #include "font.h"
  28.  
  29. union vals
  30.   {
  31.     double c_d;
  32.     char *c_s;
  33.     long c_l;
  34.     int c_i;
  35.     struct rng c_r;
  36.   };
  37.  
  38. /* An actual cell structure.  These cannot be variable-length, since they are
  39.    allocated as a variable-length array on a col structure. */
  40.  
  41. struct cell
  42.   {
  43.     /* char *cell_string; */
  44.     short cell_flags;
  45.     struct font_memo * cell_font;
  46.     struct ref_fm *cell_refs_from;
  47.     struct ref_to *cell_refs_to;
  48.     unsigned char *cell_formula;
  49.     unsigned short cell_cycle;
  50.     union vals c_z;
  51.   };
  52.  
  53. struct var
  54.   {
  55.     struct var *var_next;
  56.  
  57.     short var_flags;
  58.     struct rng v_rng;
  59.  
  60.     /* This is a list of the cells that reference this variable.  If the variable
  61.    changes, all the cells in the vars new range must be given ref_froms that
  62.    point to these variables */
  63.     struct ref_fm *var_ref_fm;
  64.     /* A variable sized array that holds the var-name. */
  65.     char var_name[1];
  66.   };
  67.  
  68. typedef struct cell CELL;
  69.  
  70. #define VAR_UNDEF 1
  71. #define VAR_CELL 2
  72. #define VAR_RANGE 3
  73.  
  74. /* Shorthand for the cell union */
  75. #define cell_flt    c_z.c_d
  76. #define cell_str    c_z.c_s
  77. #define cell_int    c_z.c_l
  78. #define cell_bol    c_z.c_i
  79. #define cell_err    c_z.c_i
  80.  
  81. /* cell_flags is a 16bit value.  These bits have the following values
  82. 15   14   13   12 . 11   10    9    8  . 7    6    5    4  . 3    2    1    0 .
  83.  Unused | --Lock- | ----Type---- | Justify  | - Format --  | --- Precision ---
  84.  */
  85.  
  86. #define GET_LCK(p)    ((p)->cell_flags & 0x3000)
  87. #define SET_LCK(p,x)    (((p)->cell_flags &= ~0x3000),(p)->cell_flags |= x)
  88.  
  89. #define LCK_DEF        (0x0000)
  90. #define LCK_UNL        (0x1000)
  91. #define LCK_LCK        (0x2000)
  92.  
  93. /* The type of a cell, or of a eval_expression() value */
  94. #define GET_TYP(p)    ((p)->cell_flags & 0x0E00)
  95. #define SET_TYP(p,x)    ((p)->cell_flags &= ~0x0E00,(p)->cell_flags|=(x))
  96. #define TYP_FLT    0x0200
  97. #define TYP_INT    0x0400
  98. #define TYP_STR    0x0600
  99. #define TYP_BOL    0x0800
  100. #define TYP_ERR    0x0A00
  101. /* This for the expression evaluator:  NO cell should be this type */
  102. #define TYP_RNG 0x0E00
  103.  
  104. #define GET_JST(p)    ((p)->cell_flags & 0x0180)
  105. #define SET_JST(p,x)    ((p)->cell_flags &= ~0x0180,(p)->cell_flags|=(x))
  106. #define JST_DEF    0x0000
  107. #define JST_LFT 0x0100
  108. #define JST_RGT 0x0080
  109. #define JST_CNT 0x0180
  110.  
  111. #define GET_FMT(p)    ((p)->cell_flags & 0x007F)
  112. #define SET_FMT(p,x)    ((p)->cell_flags &= ~0x007F,(p)->cell_flags|=(x))
  113. #define GET_PRC(p)    ((p)&0x0F)
  114. #define PRC_FLT    0x0F
  115. #define FMT_DEF 0x0000
  116.  
  117. #define FMT_HID 0x000E
  118. #define FMT_GPH 0x000F
  119.  
  120. #define FMT_DOL 0x001F
  121. #define FMT_CMA 0x002F
  122. #define FMT_PCT 0x003F
  123. #define FMT_USR 0x004F
  124.  
  125. #define FMT_FXT 0x005F
  126. #define FMT_EXP 0x006F
  127. #define FMT_GEN 0x007F
  128.  
  129. #define FMT_MAX 0x007F
  130.  
  131. /* README README README
  132.  *
  133.  * The _make_ functions may cause the addresses of cells previously returned by
  134.  * find_ functions to change.  By extention, any function that calls a make_
  135.  * function can have that effect.  This is particularly nasty because pointers
  136.  * to cells are stored in the global my_cell, and in various stack frames.
  137.  * Several bugs have been traced to this idiotic design -- please be careful
  138.  * not to add new ones.
  139.  */
  140.  
  141. #ifdef __STDC__
  142. extern CELL *find_cell (CELLREF, CELLREF);
  143. extern CELL *find_or_make_cell (CELLREF, CELLREF);
  144. extern void find_cells_in_range (struct rng *);
  145. extern void make_cells_in_range (struct rng *);
  146. extern CELL *next_cell_in_range (void);
  147. extern CELL *next_row_col_in_range (CELLREF *, CELLREF *);
  148. extern void no_more_cells (void);
  149. extern char *decomp (CELLREF, CELLREF, CELL *);
  150. extern void decomp_free (void);
  151. #else
  152. extern CELL *find_cell ();
  153. extern CELL *find_or_make_cell ();
  154. extern void find_cells_in_range ();
  155. extern void make_cells_in_range ();
  156. extern CELL *next_cell_in_range ();
  157. extern CELL *next_row_col_in_range ();
  158. extern void no_more_cells ();
  159. extern char *decomp ();
  160. extern void decomp_free ();
  161. #endif
  162.  
  163. #endif
  164.